trigger ClosedTaskDelete on Task (before delete) {
 
    All_Security_Extensions__c permissionsCS = All_Security_Extensions__c.getinstance(); 
   
    for(Task TaskOld :Trigger.old){
        if(TaskOld.status == 'Completed')
           {
             if ( permissionsCS.Can_delete_closed_tasks__c != true ){
                    TaskOld.addError('Deleting a closed task is not permitted');
                }
           }
    }
}